// import axios from 'axios'

// const _axios = axios.create({
//   baseURL: process.env.VUE_APP_BASE_API
// })

// export default _axios
import store from '@/store/index.js'
import axios from 'axios'
const request = axios.create({
  baseURL: process.env.VUE_APP_BASE_API
})
// 请求拦截器
request.interceptors.request.use(
  config => {
    config.headers.token = store.state.user.token

    // console.log(store.state.user.token)
    return config
  },
  error => {
    return Promise.reject(error)
  }
)
// 响应拦截器
request.interceptors.response.use(
  res => {
    return res.data
  },
  error => {
    return Promise.reject(error)
  }
)

// 暴露副本
export default request
